/**
 * 表示站点的类
 */
Subwaymap.Station = org.gridsofts.util.Class.define({
    name: "Subwaymap.Station",

    /**
     * 静态属性
     */
    statics: {
        // 普通站
		STATION: "station",
		// 换乘站
		TRANSFER: "transfer",
		// 三条线路换乘站
		TRANSFER3: "transfer3",
		// 半程车换乘站
		TRANSFER_HALF: "transfer_half"
    },

    /**
     * 构造函数
     */
    construct: function(container, station) {
		if (arguments.length == 0 || typeof(arguments[0]) != "object") {
			throw new Error("Object construct parameter is empty, unable to initialize instance of Station.");
		}

		this.container = container;
        this.station = station;
		
		// 站点图标半径
		this.radius = station.radius ? station.radius : 20;
		// 站点图标笔触
		this.thickness = station.radius ? station.radius / 3 : -1;
		
        // 首选颜色
		this.color1 = station.color && station.color.length > 0 ?
                        station.color : 0x0;

		this.fillColor1= station.fillColor ? station.fillColor : "ffffff";

        this.repaint();
    },

    /**
     * 方法
     */
    methods: {
		repaint: function() {
			this.actualDrawStation();
		},
		/** ***********************************************************
		 * 调用绘图API，在画布上绘制图元
		 */
		actualDrawStation: function() {
			var code=this.station.code;
			var sprite = new Kinetic.Circle({
				x: this.station.x ,
				y: this.station.y,
				name: code,
				radius: this.station.radius,
				fill: "#"+this.fillColor1,
				stroke: "#" + this.color1,
				strokeWidth: this.thickness,
			});
			/* 添加监听事件*/
			if(!this.station.disabled){
                sprite.addEventListener("click",function(){
//                    var funcs=Subwaymap.jsonObj.stationClick;
//                    if (funcs && funcs.hasOwnProperty("length") && funcs.length > 0){
//                        for(var i=0;i<funcs.length;i++){
//                            funcs[i](code);
//                        }
//                    }
                    alert(code);
                    return false;
                });
			}

			this.container.add(sprite);
		}
    }
});